package com.ruoyi.web.controller.price;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.service.UserService;
import com.ruoyi.web.domain.UpdateUserCardRequest;
import com.ruoyi.web.domain.UserPageRequest;
import com.ruoyi.web.domain.UserPageResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
@RequestMapping("/price/user")
public class UserController {
    private String prefix = "price/user";

    @Resource
    private UserService userService;

    @PostMapping("/list")
    public String page(@RequestBody UserPageRequest request , ModelMap mmap) {
        IPage<UserPageResponse> userPageResponseIPage = userService.userPageList(request);
        mmap.put("data", userPageResponseIPage);
        return prefix + "/list";
    }


    @PostMapping("/update/card")
    public String updateCard(@RequestBody UpdateUserCardRequest request , ModelMap mmap) {
        boolean isUpdate = userService.updateCard(request);
        mmap.put("isUpdate", isUpdate);
        return prefix + "/list";
    }
}
